package com.ithiema.edu.info.manager.service;

import com.ithiema.edu.info.manager.dao.TeacherDao;
import com.ithiema.edu.info.manager.domain.Teacher;
import com.ithiema.edu.info.manager.utils.Utils;

public class TeacherService {
    Utils utils = new Utils();
    TeacherDao teacherDao = new TeacherDao();
    Teacher[] teas = teacherDao.findAllTeacher();
    public boolean addTeacher(Teacher teacher) {
        return teacherDao.addTeacher(teacher);
    }

    public boolean seekIndex(String id) {
        return utils.seekIndex(id,teas);
    }

    public void showTeacher() {
        if(teacherDao.findCount() == 0){
            System.out.println("无教师信息");
            return;
        }
        System.out.println("编号\t\t姓名\t\t性别\t\t年龄");
        for (int i = 0; i < teas.length; i++) {
            Teacher tea = teas[i];
            if(tea == null){
                return;
            }
            System.out.println(tea.getId()+"\t"+tea.getName()+"\t\t"+tea.getSex()+
                    "\t\t"+tea.getAge());
        }
    }

    public boolean deleteTeacehr(String id) {
        return teacherDao.deleteTeacehr(id);
    }

    public void reviseTeacehr(String id,Teacher teacher) {
        teacherDao.reviseTeacehr(id,teacher);
    }
}
